package com.weetop.aklyscan.presenter;

import android.app.Activity;

import com.weetop.aklyscan.base.mvp.BaseModel;
import com.weetop.aklyscan.base.mvp.BaseObserver;
import com.weetop.aklyscan.base.mvp.BasePresenter;
import com.weetop.aklyscan.bean.KuaiDiBean;
import com.weetop.aklyscan.bean.KuaiDiImgBean;
import com.weetop.aklyscan.bean.MailBean;
import com.weetop.aklyscan.bean.MailBean1;
import com.weetop.aklyscan.bean.MailNumberBean;
import com.weetop.aklyscan.bean.OfficeBean;
import com.weetop.aklyscan.bean.OnLineOrderBean;
import com.weetop.aklyscan.view.DetailedView;

import java.util.List;

public class DetailedPresent extends BasePresenter<DetailedView> {
    public DetailedPresent(DetailedView baseView, Activity activity) {
        super(baseView, activity);
    }
    public void Into77(){
        addDisposable(apiServer.Into77(), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto77Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
    public void onlineOrder(String keywords, String print_status, String print_start_time, String print_end_time) {
        if(print_status.equals("1")){
            addDisposable(apiServer.onlineOrder1("1", keywords, print_status, print_start_time, print_end_time, "1"), new BaseObserver<BaseModel<OnLineOrderBean>>(baseView) {
                @Override
                public void onSuccess(BaseModel<OnLineOrderBean> o) {
                    baseView.getonlineOrderSuccess(o);
                }

                @Override
                public void onError(String msg) {
                    if (baseView != null) {
                        baseView.showError(msg);
                    }
                }
            });
        }else {
            addDisposable(apiServer.onlineOrder("1", "1", keywords, print_status, print_start_time, print_end_time, "1"), new BaseObserver<BaseModel<OnLineOrderBean>>(baseView) {
                @Override
                public void onSuccess(BaseModel<OnLineOrderBean> o) {
                    baseView.getonlineOrderSuccess(o);
                }

                @Override
                public void onError(String msg) {
                    if (baseView != null) {
                        baseView.showError(msg);
                    }
                }
            });
        }
    }

    public void updateOrder(String order_sn) {
        addDisposable(apiServer.updateOrder("4", order_sn), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getupdateOrderSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void updateOrder1(String order_sn) {
        addDisposable(apiServer.updateOrder("4", order_sn), new BaseObserver<BaseModel<String>>(null) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getupdateOrder1Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void updateOrder2(String order_sn) {
        addDisposable(apiServer.updateOrder2("32", order_sn), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getupdateOrderSuccess2(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void updateOrder3(String order_sn) {
        addDisposable(apiServer.updateOrder3("32", order_sn), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getupdateOrderSuccess2(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }


    public void mailType() {
        addDisposable(apiServer.mailType("1", "1"), new BaseObserver<BaseModel<MailBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<MailBean> o) {
                baseView.getMailTypeSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void surplus(String com) {
        addDisposable(apiServer.surplus(com), new BaseObserver<BaseModel<MailNumberBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<MailNumberBean> o) {
                baseView.getsurplusSuccess(o, com);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.getsurplusError(msg);
                }
            }
        });
    }

    public void mailType1() {
        addDisposable(apiServer.mailType1("1", "1"), new BaseObserver<BaseModel<MailBean1>>(baseView) {
            @Override
            public void onSuccess(BaseModel<MailBean1> o) {
                baseView.getMailType1Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
    public void getKuaiDiImg(String type, String order_sn, String kuaidinum){
        addDisposable(apiServer.Into78(type, order_sn, kuaidinum),
                new BaseObserver<BaseModel<KuaiDiImgBean>>(null) {
                    @Override
                    public void onSuccess(BaseModel<KuaiDiImgBean> o) {
                        baseView.getKuaiDiImgSuccess(o);
                    }

                    @Override
                    public void onError(String msg) {
                        if (baseView != null) {
                            baseView.getKuaiDiImgError();
                            baseView.hideLoading();
                            baseView.showError(msg);
                        }
                    }
                });
    }

    public void getKuaiDiCode(String name, String mobile, String printAddr, String count, String weight, String expType,
                              String remark, String tempid, String type, String type_id, String kuaidicom) {
        addDisposable(apiServer.getKuaiDiCode(name, mobile, printAddr, count, weight, "", expType, remark, tempid, type, type_id, kuaidicom),
                new BaseObserver<BaseModel<KuaiDiBean>>(null) {
                    @Override
                    public void onSuccess(BaseModel<KuaiDiBean> o) {
                        baseView.getKuaiDiCodeSuccess(o);
                    }

                    @Override
                    public void onError(String msg) {
                        if (baseView != null) {
                            baseView.onUpFail("1");
                        }
                    }
                });
    }


    public void office(String keywords, String print_status, String start_time, String stop_time) {
        addDisposable(apiServer.office("1", keywords, "1", print_status, start_time, stop_time, "1", "10000"),
                new BaseObserver<BaseModel<OfficeBean>>(baseView) {
                    @Override
                    public void onSuccess(BaseModel<OfficeBean> o) {
                        baseView.getofficeSuccess(o);
                    }

                    @Override
                    public void onError(String msg) {
                        if (baseView != null) {
                            baseView.showError(msg);
                        }
                    }
                });
    }

    public void office1(String keywords, String print_status, String start_time, String stop_time) {
        addDisposable(apiServer.office1("1", keywords, print_status, start_time, stop_time, "1", "10000"),
                new BaseObserver<BaseModel<OfficeBean>>(baseView) {
                    @Override
                    public void onSuccess(BaseModel<OfficeBean> o) {
                        baseView.getofficeSuccess(o);
                    }

                    @Override
                    public void onError(String msg) {
                        if (baseView != null) {
                            baseView.showError(msg);
                        }
                    }
                });
    }

    public void Into52(String order_sn, String express_sn, String partner_id, String actual_weight, String cube, String remarks, String express_name,
                       String partner_type) {
        addDisposable(apiServer.Into52(order_sn, express_sn, partner_id, actual_weight, cube, remarks, express_name, partner_type),
                new BaseObserver<BaseModel<String>>(baseView) {
                    @Override
                    public void onSuccess(BaseModel<String> o) {
                        baseView.getUpOrderSuccess(o);
                    }

                    @Override
                    public void onError(String msg) {
                        if (baseView != null) {
                            baseView.showError(msg);
                        }
                    }
                });
    }

    public void Into59(String order_sn, String express_sn, String partner_id, String actual_weight, String cube, String remarks, String express_name,
                       String partner_type) {
        addDisposable(apiServer.Into59(order_sn, express_sn, partner_id, actual_weight, cube, remarks, express_name, partner_type),
                new BaseObserver<BaseModel<String>>(baseView) {
                    @Override
                    public void onSuccess(BaseModel<String> o) {
                        baseView.getUpOrderSuccess(o);
                    }

                    @Override
                    public void onError(String msg) {
                        if (baseView != null) {
                            baseView.showError(msg);
                        }
                    }
                });
    }

    public void repairList(String keywords, String print_status, String start_time, String stop_time) {
        addDisposable(apiServer.repairList("6", keywords, print_status, start_time, stop_time, "1", "10000"), new BaseObserver<BaseModel<OfficeBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<OfficeBean> o) {
                baseView.getofficeSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

}